package com.fwj.core.common.model;

/**
 * @Author: fwj
 * @Data: 2021/12/17 14:40
 * @Version 1.0
 * @Description:
 * 1、响应码不该私自定义，尤其是使用HTTP状态码
 * 2、定义响应码应该符合实际，确保能准确表达所想表达的
 * 3、定义响应码需在分类下定义，不要随处定义
 * 4、响应码返回给前端的是其定义的解释，不是响应码本身
 * 5、响应码可以与响应消息有出入，不必一一对应
 * @LastUpdateTime: 2021/12/17 14:48
 */


public enum ResponseEnum {


    /* 示例，不要使用http状态码作为响应码 */
    EXAMPLE_RESPONSE_ENUM(404,"example","示范响应码"),

    /* 请求成功 */
    /**
     * 请求数据成功
     * */
    SUCCESS(10000,"success","请求成功"),

    /* 请求失败 */
    /**
     * 因为未知原因导致失败，统一回复服务器内部错误
     * */
    SERVER_ERROR(20000,"error","服务器内部错误"),
    /**
     * 缺少参数异常
     * */
    MISS_PARAMETER(20001,"miss parameter","缺少必要的参数"),
    /**
     * 参数错误
     * */
    ERROR_PARAMETER(20002,"error parameter","错误的参数"),
    /**
     * 数据转化错误
     * */
    DATA_CONVERSION_ERROR(21000,"error","数据转化错误"),
    /**
     * 文件缺少
     * */
    FILE_MISS(22000,"file miss","文件缺少"),
    /**
     * 文件类型有误
     * */
    FILE_TYPE_ERROR(22001,"file type error","文件类型有误"),
    /**
     * 文件上传失败
     * */
    FILE_UPLOAD_ERROR(22002,"file upload error","文件上传失败"),
    /**
     * 文件上传失败
     * */
    FILE_NOT_EXISTS(22003,"file not exists","文件不存在"),
    /**
     * 邮件发送失败
     * */
    MAIL_SEND_FAIL(22003,"mail send fail","邮件发送失败"),
    /* 用户 */
    /**
     * 用户未登录
     * */
    USER_NO_LOGIN(30000,"no Login","用户未登录"),
    /**
     * 用户权限不足
     * */
    USER_NO_ACCESS(30001,"no access","权限不足，禁止访问"),
    /**
     * 用户不存在
     * */
    USER_NO_EXISTS(30002,"no exists","用户不存在"),
    /**
     * 用户已存在
     * */
    USER_EXISTS(30003,"exists","用户已存在"),
    /**
     * 密码输入错误
     * */
    LOGIN_PASSWORD_ERROR(30004,"password error","密码输入错误"),
    /**
     * 用户已被冻结
     * */
    USER_FROZEN(30005,"user is frozen","用户已被冻结"),
    /**
     * 角色已关联
     * */
    USER_ROLE_ASSOCIATED(31000,"user role is Associated","角色已关联"),
    /**
     * 角色未关联
     * */
    USER_ROLE_NO_ASSOCIATE(31001,"user role no Associate","角色未关联"),
    /**
     * 权限已关联
     * */
    USER_AUTH_ASSOCIATED(31002,"user auth is Associated","权限已关联"),
    /**
     * 权限未关联
     * */
    USER_AUTH_NO_ASSOCIATE(31003,"user auth no Associate","权限未关联"),
    IDENTITY_CODE_ERROR(32002, "identityCode error", "验证码错误"),
    ;
    //定义枚举类需要将枚举值写在最上，否则会报错
    private final int code;
    private final String message;
    private final String explanation;

    ResponseEnum(int code, String message, String explanation) {
        this.code = code;
        this.message = message;
        this.explanation = explanation;
    }

    public String getExplanation() {
        return explanation;
    }

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

}
